﻿using cnBlogLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace cnBlogs.ViewModel
{
    class Top48hourArticleViewModel : MainPageViewModel
    {
        string _topEnum;
        public string Display { get; set; }
        protected override string GetPostContent_String()
        {
            return "{\"CategoryType\":\"" + _topEnum + "\",\"ParentCategoryId\":0,\"CategoryId\":0,\"PageIndex\":" + this._pageCount + ",\"ItemListActionName\":\"PostList\"}";
        }

        public Top48hourArticleViewModel(TopArticleEnum topEnum)
        {
            switch (topEnum)
            {
                case TopArticleEnum.Top48Hour:
                    _topEnum = "TopViews";
                    Display = "48小时最热文章排行";
                    break;
                case TopArticleEnum.TopTenDay:
                    _topEnum = "TopDiggs";
                    Display = "10天内推荐排行";
                    break;
                default:
                    break;
            }
        }

        protected override async Task<List<Model.ArticleInfo>> IncrementalM(uint pageCount)
        {
            _pageCount = pageCount;
            this.SetReferrer("http://www.cnblogs.com/aggsite/" + _topEnum + "/" + _pageCount);
            await PostString();
            return this._rangeList;
        }

        protected override string GetUrl()
        {
            return AppResource.cnBlogsUlr + "mvc/AggSite/PostList.aspx";
        }
    }
    public enum TopArticleEnum
    {
        Top48Hour,
        TopTenDay
    }
}
